﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Text;
using OgilvyOne.BLL;
using OgilvyOne.Model;
using System.Xml.Linq;
using System.Linq;
using OgilvyOne.UKNow.BLL;
using System.Collections.Generic;
using ECCIT;
using ECCIT.Web;
using OgilvyOne.UKNow.Model;


public partial class admin_UKNOW_seo : AdminBasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.header.Text = new ColumnBll().LayeridColumnConNaiv(Layerid);
            if (Request.Params["SeoID"] != null && Request.Params["SeoID"] != "")
            {
                int column = int.Parse(Request.QueryString["columnid"]);
                int aid = int.Parse(Request.Params["SeoID"]);
                StaticGeneratableModel cm = (StaticGeneratableModel)GenerateHtmlFactory.CreateInstance(column, this.LangID).GetSEOInfo(aid).ReturnObject;
                this.header.Text = this.header.Text + "&nbsp;&nbsp;<img src='../images/subnav_dot.gif' />&nbsp;&nbsp;" + cm.HtmlFileName;
                this.aid.Value = aid.ToString();
                this.title.Text = cm.SEOTitle;
                this.keywords.Text = cm.SEOMetaKeywords;
                this.metadesc.Text = cm.SEOMetaDescription;
                if (cm.HtmlFileName == null || cm.HtmlFileName.Trim() == "")
                {
                    this.staticpagename.Text = aid + ".html";
                }
                else
                {
                    this.staticpagename.Text = cm.HtmlFileName;
                }
                this.isstaticpub.Text =( cm.IsHtmlFile?1:0).ToString();
            }
        }
    }
    protected void Sub_click(object sender, EventArgs e)
    {
        int column = int.Parse(Request.QueryString["columnid"]);
        int aid = int.Parse(this.aid.Value);
        StaticGeneratableModel model = new StaticGeneratableModel();
        model.ColumnID = column;
        model.HtmlFileName = staticpagename.Text;
        model.IsHtmlFile = isstaticpub.SelectedValue == "0" ? false : true;
        model.SEOMetaDescription = metadesc.Text;
        model.SEOMetaKeywords = keywords.Text;
        model.SEOTitle = title.Text;
        model.ID = aid;
        IGenerateHtml bll = GenerateHtmlFactory.CreateInstance(column, this.LangID);
        ResultInfo res = bll.SaveSEOInfo(model);
        if (res.Result)
        {
            Response.Write("<script>alert('保存成功');window.close(); </script>");
        }
        else
        {
            Response.Write(res.Message);
            Response.Write("<script>alert('保存失败');</script>"); 
        }
        
    }
}